//
//  VipTypeCollectionViewCell.m
//  TQY
//
//  Created by 甘世清 on 2024/10/19.
//

#import "VipTypeCollectionViewCell.h"

@implementation VipTypeCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    self.contentView.backgroundColor = SQColor(@"#E8E8E8");
    self.contentView.layer.cornerRadius = 12;
    self.contentView.layer.masksToBounds = YES;
    UIView * bgView= [[UIView alloc]init];
    bgView.backgroundColor  = SQColor(@"#FFFFFF");
    bgView.layer.cornerRadius = 12;
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(40, 2, 2, 2));
    }];
    [self.contentView addSubview:self.TopLabel];
    [self.TopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).offset(11);
            make.centerX.equalTo(self.contentView);
        make.height.mas_equalTo(20);
    }];
    [bgView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.contentView);
        make.top.equalTo(bgView).offset(15);
    }];
    [self.contentView addSubview:self.lineLabel];
    [self.lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-16);
            make.left.right.equalTo(self.contentView);
    }];
}
- (void)setModel:(VipModel *)model{
    _model = model;
    if (model.isseleted) {
        self.contentView.backgroundColor =  SQColor(@"#212121");
        self.nameLabel.textColor = SQColor(@"#8760FF");
        self.TopLabel.textColor = SQColor(@"#8760FF");
        self.lineLabel.textColor = SQColor(@"#999999");
    } else {
        self.contentView.backgroundColor = SQColor(@"#E8E8E8");
        self.nameLabel.textColor = SQColor(@"#BEBEBE");
        self.TopLabel.textColor = SQColor(@"#BEBEBE");
        self.lineLabel.textColor = SQColor(@"#D8D8D8");
    }
    self.TopLabel.text = model.name;
    self.nameLabel.text = [NSString stringWithFormat:@"%@%@",model.prefix,model.price];
    self.nameLabel.keywords = model.prefix;
    self.nameLabel.keywordsFont = FONT_MEDIUM(16);
    [self.nameLabel getLableSizeWithMaxWidth:100];
    self.lineLabel.text =[NSString stringWithFormat:@"%@%@",model.prefix,model.orgPrice];
    self.lineLabel.deletelineStr = [NSString stringWithFormat:@"%@%@",model.prefix,model.orgPrice];
    [self.lineLabel getLableSizeWithMaxWidth:200];
}
- (UILabel *)TopLabel{
    if (!_TopLabel) {
        _TopLabel = [[UILabel alloc]init];
        _TopLabel.textColor = UIColor.blackColor;
        _TopLabel.numberOfLines = 0;
        _TopLabel.font = FONT_MEDIUM(14);
    }
    return _TopLabel;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = UIColor.blackColor;
        _nameLabel.adjustsFontSizeToFitWidth = YES;
        _nameLabel.font = FONT_MEDIUM(28);
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _nameLabel;
}
- (UILabel *)lineLabel{
    if (!_lineLabel) {
        _lineLabel = [[UILabel alloc]init];
        _lineLabel.textColor = SQColor999999;
        _lineLabel.adjustsFontSizeToFitWidth = YES;
        _lineLabel.font = FONT_REGULAR(14);
        _lineLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _lineLabel;
}
@end
